package com.baomidou.springboot.controller.user;

import com.baomidou.springboot.common.SortEnum;
import com.baomidou.springboot.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;

@Controller("IndexController")
public class IndexController {

    @Autowired
    private AboutService aboutService;
    @Autowired
    private NewsService newsService;
    @Autowired
    private NoticeService noticeService;
    @Autowired
    private ActivityService activityService;
    @Autowired
    private AuthenticateService authenticateService;
    @Autowired
    private ClientService clientService;
    @Autowired
    private QualityService qualityService;
    @Autowired
    private EnvironmentService environmentService;
    @Autowired
    private HealthService healthService;
    @Autowired
    private HssseService hssseService;
    @Autowired
    private FileService fileService;

    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public String index(HttpServletRequest request) {
        // 关于我们子菜单
        request.setAttribute("aboutMenuList", aboutService.findBySort(SortEnum.ASC));
        // 新闻的动态子菜单
        request.setAttribute("newsMenuList", newsService.findBySort(SortEnum.ASC));
        // 中心简介内容
        request.setAttribute("about", aboutService.findOneBySort(SortEnum.ASC));
        // 重要通知列表
        request.setAttribute("noticeList", noticeService.findByLimit(8));
        // 质量管理体系子菜单
        request.setAttribute("qualityList", qualityService.findBySort());
        // 环境管理体系子菜单
        request.setAttribute("environmentList", environmentService.findBySort());
        // 职业健康安全管理体系子菜单
        request.setAttribute("healthList", healthService.findBySort());
        // hssse体系子菜单
        request.setAttribute("hssseList", hssseService.findBySort());
        // 新闻动态列表
        request.setAttribute("newsList", newsService.findByLimit(8));
        // 培训之窗列表
        request.setAttribute("trainingList", newsService.findByMenuAndLimit("培训专栏", 8));
        // 公开文件列表
        request.setAttribute("fileList", fileService.findByLimit(8));
        // 专题活动列表
        request.setAttribute("activityList", activityService.findByLimit(2));
        // 认证流程
        request.setAttribute("authenticateList", authenticateService.findBySort());
        // 优秀客户
        request.setAttribute("clientList", clientService.findBySort(SortEnum.ASC));
        return "user/index";
    }

}
